{include file='common/_meta' /}
<body>
<div class="container">

    <form class="layui-form layui-col-xs12 layui-col-sm6" action="" lay-filter="form-filter" id="form-article" >
        {volist name="configTable" id="ct"}
            {switch ct.element }
                {case select }
                    <div class="layui-row">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="custom-color-red">*</span>{$ct.title}：</label>
                            <div class="layui-input-block">
                                <select name="{$ct.field}" lay-search lay-verify="required">
                                    <option value=""></option>
                                    {volist name='ct.data' id='c'}
                                    <option value="{$c.value}">{$c.name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                    </div>

                {/case}
                {case input}
                <div class="layui-row">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="custom-color-red">*</span>{$ct.title}：</label>
                        <div class="layui-input-block">
                            <input type="text" name="{$ct.field}" value="" placeholder="{$ct.title}" class="layui-input" lay-verify="required">
                        </div>
                    </div>
                </div>
                {/case}
            {/switch}
        {/volist}
        <input type="text" name="id" value="" placeholder="" class="layui-input layui-hide" lay-verify="required">
        <div class="layui-row">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                </div>
            </div>
        </div>

    </form>

</div>
{include file="common/_footer"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
layui.use(['form'], function() {

    var layer = layui.layer;
    var form  = layui.form;

    form.val("form-filter", {
        "id": "{$oneData.id}",
        {volist name="configTable" id="c"}
        "{$c.field}": "{$oneData[$c['field']]}",
        {/volist}
    })

    //监听提交
    form.on('submit(formDemo)', function(data) {
        var index = layer.load();

        $.ajax({
            type : "POST",
            url  : "{$posturl}",
            data : $("#form-article").serialize(),
            success : function(e){
                layer.close(index);
                if(e.code != 200){
                    layer.msg(e.msg,{icon: 5,time:3000});
                    return false;
                }
                layer.msg('修改成功',{icon:1,time:1000},function(){layer.open({type: 3});parent.location.reload();});
            },
            error : function(e){
                layer.close(index);
                layer.msg('修改错误',{icon: 5,time:3000});
            }
        });

        return false;
    });

});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>